package com.gexiaobao.pigeon.ui.activity.bank

import android.os.Bundle
import androidx.activity.OnBackPressedCallback
import com.gexiaobao.pigeon.R
import com.gexiaobao.pigeon.app.base.BaseActivity
import com.gexiaobao.pigeon.app.ext.initClose
import com.gexiaobao.pigeon.app.util.RxToast
import com.gexiaobao.pigeon.databinding.ActivitySigningDocumentBinding
import com.gexiaobao.pigeon.ui.activity.LoginActivity
import com.gexiaobao.pigeon.viewmodel.DocumentViewModel
import me.hgj.jetpackmvvm.util.startActivity

/**
 * @Author      : hxw
 * @Date        : 2024/4/11 9:01
 * @Describe    : 签约文件
 */
class ActivitySigningDocument : BaseActivity<DocumentViewModel, ActivitySigningDocumentBinding>() {

    private var exitTime = 0L

    override fun initView(savedInstanceState: Bundle?) {
        mDatabind.includeBar.toolbar.initClose(getString(R.string.signed_instrument)) {
            logout()
        }
        onBackPressedDispatcher.addCallback(this, object : OnBackPressedCallback(true) {
            override fun handleOnBackPressed() {
                logout()
            }
        })
    }

    private fun logout() {
        if (System.currentTimeMillis() - exitTime > 2000) {
            RxToast.showToast(getString(R.string.exit_program))
            exitTime = System.currentTimeMillis()
        } else {
            startActivity<LoginActivity>()
            finish()
        }
    }
}